#ifndef _THREADPOOL_H_
#define _THREADPOOL_H_

#include <pthread.h>
#include <semaphore.h>
#define MAX_NUM_JOB 20

//define the Job node
typedef struct Thread_Job
{
    int num;
}threadjob;

typedef struct Job_Queue_Control
{
    int readpos;
    int writepos;
    int jobcount;
}jobqueuectl;

//define the ThreadPool
typedef struct Thread_Pool
{
	pthread_t * threadidarr;	 //the array of record every threads' id
	int max_thread_num;          //the max num of thread
	pthread_mutex_t queue_lock;
    sem_t * sem_arr;
	int shutdown;               //1-close 0-open
}thpool;

//functions for ThreadPool
int Theadpool_create(int threadN);	//create the threadpool

//add job to Queue
int Threadpool_add_job(void *arg);

int Threadpool_destroy(void);	//destroy the threadpool

//int Threadpool_jobq_init(thpool * pool);

//thread gets job from jobqueue
void Thread_do_job(int threadno);

int PrintJobs(void);

#endif
